package com.hl.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.domain.Free;
import com.hl.domain.Teacher;
import com.hl.mapper.TeacherMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * @author Hr
 * @date 2024/9/6 8:55
 */
@Service
public class TeacherService {

    @Autowired
    private TeacherMapper teacherMapper;

    //查询所有老师
    public List<Teacher> findAllTeacher() {
        return teacherMapper.findAllTeacher();
    }
//    联表查询teacher和consultwait
    public List<Teacher> findAllAndChild(){
        return teacherMapper.findAllAndChild();
    }
    public List<Teacher> findAllAndChild2(){
        return teacherMapper.findAllAndChild2();
    }


    //根据老师id查老师等级
    public Teacher selectLevelByTeacherId(int id){
        return teacherMapper.selectLevelByTeacherId(id);
    }

    //查询所有老师及相关等级信息
    public HashMap<String, Object> selectAllTeacherInfo(int page, int size){
        //设置分页
        PageHelper.startPage(page, size);
        //查询全部数据
        List<Teacher> list = teacherMapper.selectAllTeacherInfo();
        PageInfo<Teacher> pageInfo = new PageInfo<Teacher>(list);
        //获取总数
        int total = (int) pageInfo.getTotal();
        HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("list", list);
        map.put("total", total);
        return map;
    }

    //根据id查询需要的老师信息
    public Teacher selectAllById(int id){
        return teacherMapper.selectAllById(id);
    }

    //根据id查询收费信息
    public List<Teacher> selectCharge(int id){
        return teacherMapper.selectCharge(id);
    }

    //获取问题与回复
    public List<Teacher> selectProblemAndAnswer(){
        return teacherMapper.selectProblemAndAnswer();
    }

    //查询用户评价
    public List<Teacher> selectUserMarkById(int id){
        return teacherMapper.selectUserMarkById(id);
    }

}
